home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / fractals / mandelsquare / mandelsquare-1.06.lha / unvscomp.asm < prev   
Assembly Source File  |  1992-08-29  |  6KB  |  171 lines

  1. ;
  2. ; This file is presented exactly as found in the file riffsrc.arc on the BIX
  3. ; listings area for the AMiga except for the addition of the README file 
  4. ; from the same arc file at the front end.  This was added to justify the
  5. ; PD nature of this code despite the existence of the copyright notice in
  6. ; the original file.
  7. ;
  8. ; *** README file ***
  9. ;
  10. ; Hello
  11. ;     here's the source code in Aztec C and assembler for Playriff. 
  12. ; It must be compiled with 32-bit-ints.  Though the code is PD and may
  13. ; be put to whatever use you see fit, I'm not giving away free consulting
  14. ; time to support it.  Nevertheless here's how to get in touch with me
  15. ; if you have some questions.
  16. ;    Jim Kent
  17. ;    Dancing Flame
  18. ;    739A 16th Ave.
  19. ;    San Francisco, CA 94118
  20. ;    or jim_kent on BIX.
  21. ;
  22. ; *** unvscomp.asm file ***
  23. ;
  24. ; unvscomp.asm  Copyright 1987 Dancing Flame all rights reserved.
  25. ;
  26. ; This file contains a single function which is set up to be called from
  27. ; C.  Ie the parameters are on the stack instead of registers.
  28. ;       decode_vkplane(in, out, linebytes)
  29. ; where in is a bit-plane's worth of vertical-byte-run-with-skips data
  30. ; and out is a bit-plane that STILL has the image from last frame on it.
  31. ; Linebytes is the number of bytes-per-line in the out bitplane, and it
  32. ; should certainly be noted that the external pointer variable ytable
  33. ; must be initialized to point to a multiplication table of
  34. ; 0*linebytes, 1*linebytes ... n*linebytes  before this routine is called.
  35. ; The format of "in":
  36. ;   Each column of the bitplane is compressed separately.  A 320x200
  37. ;   bitplane would have 40 columns of 200 bytes each.  The linebytes
  38. ;   parameter is used to count through the columns, it is not in the
  39. ;   "in" data, which is simply a concatenation of columns.
  40. ;
  41. ;   Each columns is an op-count followed by a number of ops.
  42. ;   If the op-count is zero, that's ok, it just means there's no change
  43. ;   in this column from the last frame.
  44. ;   The ops are of three classes, and followed by a varying amount of
  45. ;   data depending on which class.
  46. ;       1. Skip ops - this is a byte with the hi bit clear that says how many
  47. ;          rows to move the "dest" pointer forward, ie to skip. It is non-
  48. ;          zero
  49. ;       2. Uniq ops - this is a byte with the hi bit set.  The hi bit is
  50. ;          masked down and the remainder is a count of the number of bytes
  51. ;          of data to copy literally.  It's of course followed by the
  52. ;          data to copy.
  53. ;       3. Same ops - this is a 0 byte followed by a count byte, followed
  54. ;          by a byte value to repeat count times.
  55. ;   Do bear in mind that the data is compressed vertically rather than
  56. ;   horizontally, so to get to the next byte in the destination (out)
  57. ;   we add linebytes instead of one!
  58. ;
  59. ;   ************************************************************
  60. ;
  61. ;   A quick note on the remainder of the following source code:
  62. ;
  63. ;   In order to get this cutie to assemble and work under SAS/C I had
  64. ;   to rewrite small portions of the code, namely the register indexing
  65. ;   for the jump table. Except for Manx `as' and Charlie Gibb's `a68k' any
  66. ;   other assembler would default the data register indexed jump to a long
  67. ;   offset which would cause a jump to `unknown territories' (throughout
  68. ;   the whole code only word width data registers are used). I also made
  69. ;   a few changes to the number of registers saved and introduced a couple
  70. ;   of magic SAS/C keywords, notably the line offset table is passed in
  71. ;   a3 rather than set up by the code itself.
  72. ;                                             -olsen
  73.  
  74.     csect    text,0,0,1,2
  75.  
  76.     xdef    _decode_vkplane
  77.  
  78. _decode_vkplane:
  79.  
  80.     movem.l    d3-d5,-(sp)        ; save registers for Aztec C
  81.     move.w    d2,d4            ; make a copy of linebytes to use as a counter
  82.     bra    zdcp            ; And go to the "columns" loop
  83.  
  84. dcp    move.l    a2,a1            ; get copy of dest pointer
  85.     clr.w    d0            ; clear hi byte of op_count
  86.     move.b    (a0)+,d0        ; fetch number of ops in this column
  87.     bra    zdcvclp            ; and branch to the "op" loop.
  88.  
  89. dcvclp    clr.w    d1            ; clear hi byte of op
  90.     move.b    (a0)+,d1        ; fetch next op
  91.     bmi    dcvskuniq        ; if hi-bit set branch to "uniq" decoder
  92.     beq    dcvsame            ; if it's zero branch to "same" decoder
  93.  
  94. skip                    ; otherwise it's just a skip
  95.     add.w    d1,d1            ; use amount to skip as index into word-table
  96.     adda.w    0(a3,d1.w),a1
  97.     dbf    d0,dcvclp        ; go back to top of op loop
  98.     bra    z1dcp            ; go back to column loop
  99.  
  100. dcvsame                    ; here we decode a "vertical same run"
  101.     move.b    (a0)+,d1        ; fetch the count
  102.     move.b    (a0)+,d3        ; fetch the value to repeat
  103.     move.w    d1,d5            ; and do what it takes to fall into a "tower"
  104.     asr.w    #3,d5            ; d5 holds # of times to loop through tower
  105.     and.w    #7,d1            ; d1 is the remainder
  106.     add.w    d1,d1
  107.     add.w    d1,d1
  108.     neg.w    d1
  109.     jmp    32+same_tower(pc,d1.w)    ; 8*size of tower
  110.  
  111. same_tower
  112.     move.b    d3,(a1)
  113.     adda.w    d2,a1
  114.     move.b    d3,(a1)
  115.     adda.w    d2,a1
  116.     move.b    d3,(a1)
  117.     adda.w    d2,a1
  118.     move.b    d3,(a1)
  119.     adda.w    d2,a1
  120.     move.b    d3,(a1)
  121.     adda.w    d2,a1
  122.     move.b    d3,(a1)
  123.     adda.w    d2,a1
  124.     move.b    d3,(a1)
  125.     adda.w    d2,a1
  126.     move.b    d3,(a1)
  127.     adda.w    d2,a1
  128.     dbf    d5,same_tower
  129.     dbf    d0,dcvclp
  130.     bra    z1dcp
  131.  
  132. dcvskuniq                ; here we decode a "unique" run
  133.     and.b    #$7f,d1            ; setting up a tower as above....
  134.     move.w    d1,d5
  135.     asr.w    #3,d5
  136.     and.w    #7,d1
  137.     add.w    d1,d1
  138.     add.w    d1,d1
  139.     neg.w    d1
  140.     jmp    32+uniq_tower(pc,d1.w)
  141.  
  142. uniq_tower
  143.     move.b    (a0)+,(a1)
  144.     adda.w    d2,a1
  145.     move.b    (a0)+,(a1)
  146.     adda.w    d2,a1
  147.     move.b    (a0)+,(a1)
  148.     adda.w    d2,a1
  149.     move.b    (a0)+,(a1)
  150.     adda.w    d2,a1
  151.     move.b    (a0)+,(a1)
  152.     adda.w    d2,a1
  153.     move.b    (a0)+,(a1)
  154.     adda.w    d2,a1
  155.     move.b    (a0)+,(a1)
  156.     adda.w    d2,a1
  157.     move.b    (a0)+,(a1)
  158.     adda.w    d2,a1
  159.     dbf    d5,uniq_tower        ; branch back up to "op" loop
  160. zdcvclp dbf    d0,dcvclp        ; branch back up to "column loop"
  161.  
  162.                     ; now we've finished decoding a single column
  163. z1dcp    addq.l    #1,a2            ; so move the dest pointer to next column
  164. zdcp    dbf    d4,dcp            ; and go do it again what say?
  165.     movem.l    (sp)+,d3-d5
  166.     rts
  167.  
  168.     end
  169.